Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Added Compiler Wrapper script for Preprocessing using fypp #729

Open
wants to merge 9 commits into
base: main
Choose a base branch
from

Conversation

arteevraina
Copy link
Member

@arteevraina arteevraina commented Aug 14, 2022

  • This Pull Request adds a compiler wrapper script for preprocessing the .fypp files and storing them inside the build directory.
  • Also makes the macros defined in manifest available while running tests.

@arteevraina arteevraina marked this pull request as draft August 14, 2022 13:12
@arteevraina
Copy link
Member Author

Hi @awvwgk , Can you review this new script that I created using python ?

@awvwgk awvwgk self-requested a review August 20, 2022 08:58
fypp-gfortran.py Outdated Show resolved Hide resolved
@awvwgk
Copy link
Member

awvwgk commented Aug 20, 2022

This logic can compile the example packages checked in with

fpm run -- build -C example_packages/preprocess_fypp/ --compiler "$PWD/fypp-gfortran.py"

@arteevraina arteevraina marked this pull request as ready for review August 20, 2022 16:02
@arteevraina
Copy link
Member Author

@awvwgk Removed the unused output_dir from script. I think this PR is ready for review.

@awvwgk
Copy link
Member

awvwgk commented Aug 20, 2022

There seems to be an issue with the macro scope. The macros set in the manifest are not visible when compiling tests:

❯ cat stdlib/fpm.toml
name = "stdlib"

[dev-dependencies]
test-drive.git = "https://github.com/fortran-lang/test-drive.git"

[build]
auto-examples = false
auto-tests = true

[preprocess.cpp]
macros = [
  "PROJECT_VERSION_MAJOR=0",
  "PROJECT_VERSION_MINOR=1",
  "PROJECT_VERSION_PATCH=0",
  "MAXRANK=4",
]
❯ fpm run -- build --compiler "$PWD/fypp-gfortran.py" -C stdlib
Project is up to date
fpm: Entering directory '/home/awvwgk/projects/src/git/fortran-package-manager/stdlib'
...
libstdlib.a                            done.
[100%] Project compiled successfully.
fpm: Leaving directory '/home/awvwgk/projects/src/git/fortran-package-manager/stdlib'

❯ fpm run -- test --compiler "$PWD/fypp-gfortran.py" -C stdlib
Project is up to date
fpm: Entering directory '/home/awvwgk/projects/src/git/fortran-package-manager/stdlib'
pengyhash.c                            done.
nmhash_scalar.c                        done.
waterhash.c                            done.
nmhash.c                               done.
stdlib_system.F90                      done.
stdlib_array.f90                       done.
stdlib_kinds.fypp                      done.
testdrive.F90                          done.
test_sleep.f90                         done.
stdlib_ascii.fypp                      done.
stdlib_selection.fypp                  done.
stdlib_specialfunctions.f90            done.
stdlib_io_npy.fypp                     done.
stdlib_hash_64bit.fypp                 done.
stdlib_optval.fypp                     done.
stdlib_hash_32bit.fypp                 done.
stdlib_stats.fypp                      done.
stdlib_quadrature.fypp                 done.
test_selection.fypp                    failed.
[ 10%] Compiling...
./include/common.fypp:4: error: exception occurred when setting variable(s) 'PROJECT_VERSION' to '"{}.{}.{}".format(PROJECT_VERSION_MAJOR, PROJECT_VERSION_MINOR, PROJECT_VERSION_PATCH)' [FyppFatalError]
error: name 'PROJECT_VERSION_MAJOR' is not defined [NameError]
Traceback (most recent call last):
  File "/home/awvwgk/projects/src/git/fortran-package-manager/fypp-gfortran.py", line 34, in <module>
    subprocess.run(
  File "/usr/lib/python3.10/subprocess.py", line 524, in run
    raise CalledProcessError(retcode, process.args,
subprocess.CalledProcessError: Command '['fypp', '-n', 'test/selection/test_selection.fypp', 'build/fypp-gfortran.py_FD8F41EC3CDC3776/stdlib/test_selection_test_selection.fypp.f90', '-I./include', '-Ibuild/fypp-gfortran.py_FD8F41EC3CDC3776', '-Ibuild/fypp-gfortran.py_3CB5FB1E2B6F713E']' returned non-zero exit status 1.

@awvwgk
Copy link
Member

awvwgk commented Aug 20, 2022

Good news is we can already compile and run all examples if build.auto-examples = true is set.

@arteevraina
Copy link
Member Author

There seems to be an issue with the macro scope. The macros set in the manifest are not visible when compiling tests:

❯ cat stdlib/fpm.toml
name = "stdlib"

[dev-dependencies]
test-drive.git = "https://github.com/fortran-lang/test-drive.git"

[build]
auto-examples = false
auto-tests = true

[preprocess.cpp]
macros = [
  "PROJECT_VERSION_MAJOR=0",
  "PROJECT_VERSION_MINOR=1",
  "PROJECT_VERSION_PATCH=0",
  "MAXRANK=4",
]
❯ fpm run -- build --compiler "$PWD/fypp-gfortran.py" -C stdlib
Project is up to date
fpm: Entering directory '/home/awvwgk/projects/src/git/fortran-package-manager/stdlib'
...
libstdlib.a                            done.
[100%] Project compiled successfully.
fpm: Leaving directory '/home/awvwgk/projects/src/git/fortran-package-manager/stdlib'

❯ fpm run -- test --compiler "$PWD/fypp-gfortran.py" -C stdlib
Project is up to date
fpm: Entering directory '/home/awvwgk/projects/src/git/fortran-package-manager/stdlib'
pengyhash.c                            done.
nmhash_scalar.c                        done.
waterhash.c                            done.
nmhash.c                               done.
stdlib_system.F90                      done.
stdlib_array.f90                       done.
stdlib_kinds.fypp                      done.
testdrive.F90                          done.
test_sleep.f90                         done.
stdlib_ascii.fypp                      done.
stdlib_selection.fypp                  done.
stdlib_specialfunctions.f90            done.
stdlib_io_npy.fypp                     done.
stdlib_hash_64bit.fypp                 done.
stdlib_optval.fypp                     done.
stdlib_hash_32bit.fypp                 done.
stdlib_stats.fypp                      done.
stdlib_quadrature.fypp                 done.
test_selection.fypp                    failed.
[ 10%] Compiling...
./include/common.fypp:4: error: exception occurred when setting variable(s) 'PROJECT_VERSION' to '"{}.{}.{}".format(PROJECT_VERSION_MAJOR, PROJECT_VERSION_MINOR, PROJECT_VERSION_PATCH)' [FyppFatalError]
error: name 'PROJECT_VERSION_MAJOR' is not defined [NameError]
Traceback (most recent call last):
  File "/home/awvwgk/projects/src/git/fortran-package-manager/fypp-gfortran.py", line 34, in <module>
    subprocess.run(
  File "/usr/lib/python3.10/subprocess.py", line 524, in run
    raise CalledProcessError(retcode, process.args,
subprocess.CalledProcessError: Command '['fypp', '-n', 'test/selection/test_selection.fypp', 'build/fypp-gfortran.py_FD8F41EC3CDC3776/stdlib/test_selection_test_selection.fypp.f90', '-I./include', '-Ibuild/fypp-gfortran.py_FD8F41EC3CDC3776', '-Ibuild/fypp-gfortran.py_3CB5FB1E2B6F713E']' returned non-zero exit status 1.

Sure will check this.

@arteevraina
Copy link
Member Author

There seems to be an issue with the macro scope. The macros set in the manifest are not visible when compiling tests:

❯ cat stdlib/fpm.toml
name = "stdlib"

[dev-dependencies]
test-drive.git = "https://github.com/fortran-lang/test-drive.git"

[build]
auto-examples = false
auto-tests = true

[preprocess.cpp]
macros = [
  "PROJECT_VERSION_MAJOR=0",
  "PROJECT_VERSION_MINOR=1",
  "PROJECT_VERSION_PATCH=0",
  "MAXRANK=4",
]
❯ fpm run -- build --compiler "$PWD/fypp-gfortran.py" -C stdlib
Project is up to date
fpm: Entering directory '/home/awvwgk/projects/src/git/fortran-package-manager/stdlib'
...
libstdlib.a                            done.
[100%] Project compiled successfully.
fpm: Leaving directory '/home/awvwgk/projects/src/git/fortran-package-manager/stdlib'

❯ fpm run -- test --compiler "$PWD/fypp-gfortran.py" -C stdlib
Project is up to date
fpm: Entering directory '/home/awvwgk/projects/src/git/fortran-package-manager/stdlib'
pengyhash.c                            done.
nmhash_scalar.c                        done.
waterhash.c                            done.
nmhash.c                               done.
stdlib_system.F90                      done.
stdlib_array.f90                       done.
stdlib_kinds.fypp                      done.
testdrive.F90                          done.
test_sleep.f90                         done.
stdlib_ascii.fypp                      done.
stdlib_selection.fypp                  done.
stdlib_specialfunctions.f90            done.
stdlib_io_npy.fypp                     done.
stdlib_hash_64bit.fypp                 done.
stdlib_optval.fypp                     done.
stdlib_hash_32bit.fypp                 done.
stdlib_stats.fypp                      done.
stdlib_quadrature.fypp                 done.
test_selection.fypp                    failed.
[ 10%] Compiling...
./include/common.fypp:4: error: exception occurred when setting variable(s) 'PROJECT_VERSION' to '"{}.{}.{}".format(PROJECT_VERSION_MAJOR, PROJECT_VERSION_MINOR, PROJECT_VERSION_PATCH)' [FyppFatalError]
error: name 'PROJECT_VERSION_MAJOR' is not defined [NameError]
Traceback (most recent call last):
  File "/home/awvwgk/projects/src/git/fortran-package-manager/fypp-gfortran.py", line 34, in <module>
    subprocess.run(
  File "/usr/lib/python3.10/subprocess.py", line 524, in run
    raise CalledProcessError(retcode, process.args,
subprocess.CalledProcessError: Command '['fypp', '-n', 'test/selection/test_selection.fypp', 'build/fypp-gfortran.py_FD8F41EC3CDC3776/stdlib/test_selection_test_selection.fypp.f90', '-I./include', '-Ibuild/fypp-gfortran.py_FD8F41EC3CDC3776', '-Ibuild/fypp-gfortran.py_3CB5FB1E2B6F713E']' returned non-zero exit status 1.

One more question regarding this.
From the logs it seems like you were able to successfully compile the files in src directory. Other than adding the fpm.toml in stdlib root directory. Did you made any changes with the source files ?

I am asking this because I am getting a module as duplicate when trying to build the source directory.

 Warning: Module estop in ./src/f18estop.f90 is a duplicate
<ERROR>*build_model*:Error: One or more duplicate module names found.

cc @awvwgk

@awvwgk
Copy link
Member

awvwgk commented Aug 21, 2022

From the logs it seems like you were able to successfully compile the files in src directory. Other than adding the fpm.toml in stdlib root directory. Did you made any changes with the source files ?

Just two submodule and a file rename.

diff --git a/src/common.fypp b/include/common.fypp
similarity index 100%
rename from src/common.fypp
rename to include/common.fypp
diff --git a/src/f08estop.f90 b/src/f08estop.f90
index 81c77f4..3fb0440 100644
--- a/src/f08estop.f90
+++ b/src/f08estop.f90
@@ -1,4 +1,4 @@
-submodule (stdlib_error) estop
+submodule (stdlib_error) f08estop
 
 implicit none
 
diff --git a/src/f18estop.f90 b/src/f18estop.f90
index 59fd0c9..241665a 100644
--- a/src/f18estop.f90
+++ b/src/f18estop.f90
@@ -1,4 +1,4 @@
-submodule (stdlib_error) estop
+submodule (stdlib_error) f18estop
 
 implicit none
 
@@ -26,4 +26,4 @@ else
 endif
 end procedure
 
-end submodule estop
+end submodule f18estop

@arteevraina
Copy link
Member Author

Hi @awvwgk ,

I have fixed the macros not being available while running tests error.
Now, I am facing some other while compiling tests in stdlib

test/stats/test_mean_f03.fypp:89:30:

   89 |                     , sum(abs(mean(d8_${k1}$, ${dim}$) -&
      |                              1
Error: There is no specific function for the generic ‘mean’ at (1)
test/stats/test_mean_f03.fypp:89:30:

   89 |                     , sum(abs(mean(d8_${k1}$, ${dim}$) -&
      |                              1
Error: There is no specific function for the generic ‘mean’ at (1)
test/stats/test_mean_f03.fypp:89:30:

   89 |                     , sum(abs(mean(d8_${k1}$, ${dim}$) -&
      |                              1
Error: There is no specific function for the generic ‘mean’ at (1)
test/stats/test_mean_f03.fypp:78:38:

   78 |         call check(error, ieee_is_nan(mean(d8_${k1}$, .false.))&
      |                                      1
Error: There is no specific function for the generic ‘mean’ at (1)
test/stats/test_mean_f03.fypp:68:26:

   68 |         call check(error, mean(d8_${k1}$), sum(real(d8_${k1}$, dp))/real(size(d8_${k1}$), dp)&
      |                          1
Error: There is no specific function for the generic ‘mean’ at (1)
test/stats/test_mean_f03.fypp:286:8:

  286 |     use test_stats_meanf03, only : collect_stats_meanf03
      |        1
Fatal Error: Cannot open module file ‘test_stats_meanf03.mod’ for reading at (1): No such file or directory
compilation terminated.

Working on a fix for this as well in stdlib.

@arteevraina
Copy link
Member Author

Hi @awvwgk ,

I have fixed the macros not being available while running tests error. Now, I am facing some other while compiling tests in stdlib

test/stats/test_mean_f03.fypp:89:30:

   89 |                     , sum(abs(mean(d8_${k1}$, ${dim}$) -&
      |                              1
Error: There is no specific function for the generic ‘mean’ at (1)
test/stats/test_mean_f03.fypp:89:30:

   89 |                     , sum(abs(mean(d8_${k1}$, ${dim}$) -&
      |                              1
Error: There is no specific function for the generic ‘mean’ at (1)
test/stats/test_mean_f03.fypp:89:30:

   89 |                     , sum(abs(mean(d8_${k1}$, ${dim}$) -&
      |                              1
Error: There is no specific function for the generic ‘mean’ at (1)
test/stats/test_mean_f03.fypp:78:38:

   78 |         call check(error, ieee_is_nan(mean(d8_${k1}$, .false.))&
      |                                      1
Error: There is no specific function for the generic ‘mean’ at (1)
test/stats/test_mean_f03.fypp:68:26:

   68 |         call check(error, mean(d8_${k1}$), sum(real(d8_${k1}$, dp))/real(size(d8_${k1}$), dp)&
      |                          1
Error: There is no specific function for the generic ‘mean’ at (1)
test/stats/test_mean_f03.fypp:286:8:

  286 |     use test_stats_meanf03, only : collect_stats_meanf03
      |        1
Fatal Error: Cannot open module file ‘test_stats_meanf03.mod’ for reading at (1): No such file or directory
compilation terminated.

Working on a fix for this as well in stdlib.

More updates,

So, I was able to compile all the tests except these two files :

  1. test/stats/test_mean_f03.fypp which is giving the errors I mentioned in the last comment.
  2. test/hash_functions/test_hash_functions.f90 which is giving me this error :
    undefined reference to generate_all_c_hash

I am currently trying to fix these and then we will be able to compile all the tests.

cc: @awvwgk

@jvdp1
Copy link
Member

jvdp1 commented Aug 24, 2022

More updates,

So, I was able to compile all the tests except these two files :

  1. test/stats/test_mean_f03.fypp which is giving the errors I mentioned in the last comment.

test_mean_f03 requires that stdlib is compiled for arrays with at least 4 dimentions (-DMAXRANK=4). Is this the case?

  1. test/hash_functions/test_hash_functions.f90 which is giving me this error :
    undefined reference to generate_all_c_hash

test_hash_functions.f90 depends on C code (generate_all_c_hash.c and others). I guess that fpm should be told that it should compile C codes too.

@arteevraina
Copy link
Member Author

More updates,
So, I was able to compile all the tests except these two files :

  1. test/stats/test_mean_f03.fypp which is giving the errors I mentioned in the last comment.

test_mean_f03 requires that stdlib is compiled for arrays with at least 4 dimentions (-DMAXRANK=4). Is this the case?

  1. test/hash_functions/test_hash_functions.f90 which is giving me this error :
    undefined reference to generate_all_c_hash

test_hash_functions.f90 depends on C code (generate_all_c_hash.c and others). I guess that fpm should be told that it should compile C codes too.

I think fpm already has the ability to compiler .c files, but generate_all_c_hash is an inside the file with the extension .cpp and that's why it is not getting compiled. Should I allow fpm to compile .cpp files or if possible migrate the function to .c file ?

 fpm run -- test --compiler "$PWD/fypp-gfortran.py" --flag -fno-range-check -C stdlib
Project is up to date
fpm: Entering directory '/home/arteev/new_fpm/fpm/stdlib'
nmhash.c                               done.
pengyhash.c                            done.
waterhash.c                            done.
nmhash_scalar.c                        done.
stdlib_array.f90                       done.
stdlib_kinds.fypp                      done.

@jvdp1
Copy link
Member

jvdp1 commented Aug 25, 2022

The issue for test_mean_f03 is that a directory build/fypp-gfortran_xxx is not provided to gfortran with the -I option. I am looking how to solve this.

cc @LKedward

@arteevraina
Copy link
Member Author

@jvdp1 @awvwgk @LKedward

Should I work on separate branch for cpp support in fpm or should I handle that in this branch only ?

@jvdp1
Copy link
Member

jvdp1 commented Aug 26, 2022 via email

@arteevraina
Copy link
Member Author

arteevraina commented Aug 26, 2022

I know as we are parsing the #include statements for .c files. Similarly, should we do it also for .cpp files? and add it to the include_dependendies
https://github.com/fortran-lang/fpm/blob/main/src/fpm_source_parsing.f90#L492

cc : @jvdp1 @LKedward

@jvdp1
Copy link
Member

jvdp1 commented Aug 29, 2022

Yes, working on a separate branch dedicated to the cpp support is wise. You can later merge it with your current branch.

Well, I am not sure how to solve this issue. @awvwgk @LKedward are most likely more able to do it than me.

@jvdp1
Copy link
Member

jvdp1 commented Aug 29, 2022

I know as we are parsing the #include statements for .c files. Similarly, should we do it also for .cpp files? and add it to the include_dependendies https://github.com/fortran-lang/fpm/blob/main/src/fpm_source_parsing.f90#L492

cc : @jvdp1 @LKedward

This has been answered in the other PR, right?

@arteevraina
Copy link
Member Author

arteevraina commented Aug 30, 2022

I know as we are parsing the #include statements for .c files. Similarly, should we do it also for .cpp files? and add it to the include_dependendies https://github.com/fortran-lang/fpm/blob/main/src/fpm_source_parsing.f90#L492
cc : @jvdp1 @LKedward

This has been answered in the other PR, right?

Yes, It has been resolved.

@arteevraina
Copy link
Member Author

The patch in PR #743 (@LKedward ) will fix the linking issue for us. But, there are two files in stdlib called nmhash.c & nmhash_scalar.c which contains definition of a function with same names nmhash32_test & nmhash32x_test. Should we opt for renaming those inside the stdlib itself ?

(env) arteev@pavilion:~/fpm$ fpm run -- test --compiler "$PWD/fypp-gfortran.py" -C stdlib
Project is up to date
fpm: Entering directory '/home/arteev/fpm/stdlib'
test_always_skip                       failed.
[100%] Compiling...
/usr/bin/ld: build/fypp-gfortran.py_5ECC72CE4779CCDA/stdlib/test_hash_functions_nmhash.c.o: in function `nmhash32_test':
nmhash.c:(.text+0x2b94): multiple definition of `nmhash32_test'; build/fypp-gfortran.py_5ECC72CE4779CCDA/stdlib/test_hash_functions_nmhash_scalar.c.o:nmhash_scalar.c:(.text+0x1970): first defined here
/usr/bin/ld: build/fypp-gfortran.py_5ECC72CE4779CCDA/stdlib/test_hash_functions_nmhash.c.o: in function `nmhash32x_test':
nmhash.c:(.text+0x2bc3): multiple definition of `nmhash32x_test'; build/fypp-gfortran.py_5ECC72CE4779CCDA/stdlib/test_hash_functions_nmhash_scalar.c.o:nmhash_scalar.c:(.text+0x199f): first defined here
collect2: error: ld returned 1 exit status
Traceback (most recent call last):
  File "/home/arteev/fpm/fypp-gfortran.py", line 14, in <module>
    subprocess.run(["gfortran"] + args, check=True)
  File "/usr/lib/python3.10/subprocess.py", line 524, in run
    raise CalledProcessError(retcode, process.args,
subprocess.CalledProcessError: Command '['gfortran', '-cpp', '-Wall', '-Wextra', '-Wimplicit-interface', '-fPIC', '-fmax-errors=1', '-g', '-fcheck=bounds', '-fcheck=array-temps', '-fbacktrace', '-fcoarray=single', '-I./include', 'build/fypp-gfortran.py_3CB5FB1E2B6F713E/stdlib/test_test_always_skip.f90.o', 'build/fypp-gfortran.py_5ECC72CE4779CCDA/stdlib/test_hash_functions_generate_hash_arrays.cpp.o', 'build/fypp-gfortran.py_5ECC72CE4779CCDA/stdlib/test_hash_functions_waterhash.c.o', 'build/fypp-gfortran.py_5ECC72CE4779CCDA/stdlib/test_hash_functions_nmhash_scalar.c.o', 'build/fypp-gfortran.py_5ECC72CE4779CCDA/stdlib/test_hash_functions_nmhash.c.o', 'build/fypp-gfortran.py_5ECC72CE4779CCDA/stdlib/test_hash_functions_SpookyV2.cpp.o', 'build/fypp-gfortran.py_5ECC72CE4779CCDA/stdlib/test_hash_functions_SpookyV2Test.cpp.o', 'build/fypp-gfortran.py_5ECC72CE4779CCDA/stdlib/test_hash_functions_pengyhash.c.o', 'build/fypp-gfortran.py_FD8F41EC3CDC3776/stdlib/libstdlib.a', '-lstdc++', '-o', 'build/fypp-gfortran.py_FD8F41EC3CDC3776/test/test_always_skip']' returned non-zero exit status 1.
<ERROR> Compilation failed for object " test_always_skip "
<ERROR>stopping due to failed compilation
STOP 1
<ERROR> Execution failed for object " fpm "
<ERROR>*cmd_run*:stopping due to failed executions
STOP 1

cc : @awvwgk

@jvdp1
Copy link
Member

jvdp1 commented Sep 4, 2022

The patch in PR #743 (@LKedward ) will fix the linking issue for us. But, there are two files in stdlib called nmhash.c & nmhash_scalar.c which contains definition of a function with same names nmhash32_test & nmhash32x_test. Should we opt for renaming those inside the stdlib itself ?

(env) arteev@pavilion:~/fpm$ fpm run -- test --compiler "$PWD/fypp-gfortran.py" -C stdlib
Project is up to date
fpm: Entering directory '/home/arteev/fpm/stdlib'
test_always_skip                       failed.
[100%] Compiling...
/usr/bin/ld: build/fypp-gfortran.py_5ECC72CE4779CCDA/stdlib/test_hash_functions_nmhash.c.o: in function `nmhash32_test':
nmhash.c:(.text+0x2b94): multiple definition of `nmhash32_test'; build/fypp-gfortran.py_5ECC72CE4779CCDA/stdlib/test_hash_functions_nmhash_scalar.c.o:nmhash_scalar.c:(.text+0x1970): first defined here
/usr/bin/ld: build/fypp-gfortran.py_5ECC72CE4779CCDA/stdlib/test_hash_functions_nmhash.c.o: in function `nmhash32x_test':
nmhash.c:(.text+0x2bc3): multiple definition of `nmhash32x_test'; build/fypp-gfortran.py_5ECC72CE4779CCDA/stdlib/test_hash_functions_nmhash_scalar.c.o:nmhash_scalar.c:(.text+0x199f): first defined here
collect2: error: ld returned 1 exit status
Traceback (most recent call last):
  File "/home/arteev/fpm/fypp-gfortran.py", line 14, in <module>
    subprocess.run(["gfortran"] + args, check=True)
  File "/usr/lib/python3.10/subprocess.py", line 524, in run
    raise CalledProcessError(retcode, process.args,
subprocess.CalledProcessError: Command '['gfortran', '-cpp', '-Wall', '-Wextra', '-Wimplicit-interface', '-fPIC', '-fmax-errors=1', '-g', '-fcheck=bounds', '-fcheck=array-temps', '-fbacktrace', '-fcoarray=single', '-I./include', 'build/fypp-gfortran.py_3CB5FB1E2B6F713E/stdlib/test_test_always_skip.f90.o', 'build/fypp-gfortran.py_5ECC72CE4779CCDA/stdlib/test_hash_functions_generate_hash_arrays.cpp.o', 'build/fypp-gfortran.py_5ECC72CE4779CCDA/stdlib/test_hash_functions_waterhash.c.o', 'build/fypp-gfortran.py_5ECC72CE4779CCDA/stdlib/test_hash_functions_nmhash_scalar.c.o', 'build/fypp-gfortran.py_5ECC72CE4779CCDA/stdlib/test_hash_functions_nmhash.c.o', 'build/fypp-gfortran.py_5ECC72CE4779CCDA/stdlib/test_hash_functions_SpookyV2.cpp.o', 'build/fypp-gfortran.py_5ECC72CE4779CCDA/stdlib/test_hash_functions_SpookyV2Test.cpp.o', 'build/fypp-gfortran.py_5ECC72CE4779CCDA/stdlib/test_hash_functions_pengyhash.c.o', 'build/fypp-gfortran.py_FD8F41EC3CDC3776/stdlib/libstdlib.a', '-lstdc++', '-o', 'build/fypp-gfortran.py_FD8F41EC3CDC3776/test/test_always_skip']' returned non-zero exit status 1.
<ERROR> Compilation failed for object " test_always_skip "
<ERROR>stopping due to failed compilation
STOP 1
<ERROR> Execution failed for object " fpm "
<ERROR>*cmd_run*:stopping due to failed executions
STOP 1

I believe that nmash.c is even not used and could be removed from stdlib. It is virtually the same file as nmash_scalar.c, as only the included .h is different. Furthermore, the nmash_scalar.h file could be avoided by providing the right macros for the nmash.h file.

@arteevraina
Copy link
Member Author

The issue for test_mean_f03 is that a directory build/fypp-gfortran_xxx is not provided to gfortran with the -I option. I am looking how to solve this.

cc @LKedward

Hi @jvdp1, Sorry for the late response on this. I think if we look on the command that is currently failing, we have two build/fypp-gfortran_xxx that are provided to gfortran with -I flag.

Command '['gfortran', '-c', '-cpp', '-fno-range-check', '-I./include', '-J', 'build/fypp-gfortran.py_5D5C753FD9D7515D', '-Ibuild/fypp-gfortran.py_5D5C753FD9D7515D', '-Ibuild/fypp-gfortran.py_7982C4100533BAB9', '-o', 'build/fypp-gfortran.py_5D5C753FD9D7515D/stdlib/test_stats_test_mean_f03.fypp.o', 'build/fypp-gfortran.py_5D5C753FD9D7515D/stdlib/test_stats_test_mean_f03.fypp.f90']' returned non-zero exit status 1.

@jvdp1
Copy link
Member

jvdp1 commented Jan 24, 2023

@awvwgk @arteevraina What should be done in this PR to merge it?

@arteevraina
Copy link
Member Author

Hi @jvdp1,
I think three PRs including this are interconnected.

  1. refactor: change in structure of stdlib in order to compiler it using fypp script stdlib#675
  2. feat: ability to read project major, minor & patch macros #766
  3. Added Compiler Wrapper script for Preprocessing using fypp #729

I will try to look again in the information shared in the PRs and try to resolve them one by one.

@jvdp1
Copy link
Member

jvdp1 commented Jan 7, 2024

@arteevraina @awvwgk @fortran-lang/fpm The issues mentioned in this thread seem to have been solved. At least I can compile this branch of stdlib with the wrapper script in this PR.

What should be done to finalize this branch? This wrapper script would be a better alternative than this proposition and partially solve this issue and this issue

cc: @jalvesz

@jalvesz
Copy link

jalvesz commented Jan 7, 2024

This is extremely interesting indeed!! it would make the whole process quite smooth! One question, I see that there is a fypp-gfortran.py script. Is this meant to be compiler dependent? Can't the pre-processing and the compiler choice for compiling be decoupled? Or is this meant to be used by the preprocessor option in the toml file as explained here https://fpm.fortran-lang.org/spec/manifest.html?highlight=fypp# such that it should be transparent for the user?
(sorry for the question, I'm just reading through the PR)

@jvdp1
Copy link
Member

jvdp1 commented Jan 7, 2024

One question, I see that there is a fypp-gfortran.py script. Is this meant to be compiler dependent? Can't the pre-processing and the compiler choice for compiling be decoupled?

IMO This was aimed to be a temporary solution before the full integration into fpm. However, I believe that the wrapper script could be made more flexible, e.g., by relying on the environment variables FPM_FC or FC.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

4 participants